#include <stdio.h>
/*用于输出结果*/
void display_int(int arr[] , int n) {
    for (int i = 0; i < n; i++) {
        printf("%d ",arr[i]);
    }
    printf("\n");
}


void arrage_int(int arr[], int n) {
    int i = 0;
    int j = n-1;

    while (i < j){
        while (i < j && arr[i] >= 0){
            i++;
        }
        while (i < j && arr[j] < 0){
            j--;
        }
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
        i++;
        j--;
    }
}

void display_char(char arr[], int n){
    for (int i = 0; i < n; i++) {
        printf("%c ",arr[i]);
    }
    printf("\n");
}

void arrage_char(char arr[], int n) {
    int i = 0;
    int j = n - 1;

    while (i < j){
        while (i < j && arr[i] >= 'a'){
            i++;
        }
        while (i < j && arr[j] <= 'Z') {
            j--;
        }

        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
        i++;
        j--;
    }
}

int main() {
    int arr1[] = {3, -1, -2, 4, 5, -6, 9};
    int arr1_len = sizeof(arr1) / sizeof(arr1[0]);
    display_int(arr1,arr1_len);
    arrage_int(arr1, arr1_len);
    display_int(arr1,arr1_len);

    char arr2[] = {'a', 'C', 'z', 'W', 'd', 'b'};
    int arr2_len = sizeof(arr2) / sizeof(arr2[0]);
    display_char(arr2, arr2_len);
    arrage_char(arr2, arr2_len);
    display_char(arr2, arr2_len);
    return 0;
}
